const app = getApp();
Component({
  options: {
    addGlobalClass: true,
    // multipleSlots: true
  },
  /**
   * 组件的属性列表
   */
  properties: {
    shoppingCartData: {
      type: Object,
      value: {
        show: false,
        list: [],
        totalMoney: 0,
        totalNum: 0,
      },
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    baseURL: app.globalData.config.baseURL,
  },
  lifetimes: {
    attached: function () {},
  },
  /**
   * 组件的方法列表
   */
  methods: {
    // 控制购物车弹层
    setLayerShow(e) {
      let {
        show
      } = e.currentTarget.dataset;
      this.triggerEvent(
        "setLayerShow",
        show != undefined ? show : !this.data.shoppingCartData.show
      );
    },
    // 清空购物车处理方法
    clearShoppingCart() {
      this.triggerEvent("clearShoppingCart");
    },
    // 通过购物车更新商品
    shoppingCartUpdateCommodity(e) {
      this.triggerEvent("shoppingCartUpdateCommodity", e.currentTarget.dataset || {});
    },
    // 查看商品详情
    goProductDetails(e) {
      this.triggerEvent('goProductDetails', e.currentTarget.dataset || {})
    },
    // 去下单
    toPlaceOrder(){
      this.triggerEvent('toPlaceOrder')
    },
  },
});